package com.cardbaobao.cardbabyclient.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.cardbaobao.cardbabyclient.ui.activity.CreditCardRaidersActivity;
import com.cardbaobao.cardbabyclient.utils.DensityUtil;

/**
 * Created by Jiangzx on 19:19.
 * 办卡攻略 标签
 */

public class RaidersLabelDelegateAdapter extends DelegateAdapter.Adapter<RecyclerView.ViewHolder> {
    private LayoutHelper layoutHelper;
    private String text;
    public RaidersLabelDelegateAdapter(LayoutHelper layoutHelper, String text) {
        this.layoutHelper=layoutHelper;
        this.text=text;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return layoutHelper;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        Context context=parent.getContext();
        TextView textView = new TextView(context);
        RecyclerView.LayoutParams params=
                new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT,
                        DensityUtil.dp2px(context,45.0f));
        textView.setGravity(Gravity.CENTER_VERTICAL);
        textView.setPadding(DensityUtil.dp2px(context,15.0f),0,0,0);
        textView.setTextColor(0xff666666);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,14.0f);
        textView.setLayoutParams(params);
        return new HotTopicHolder(textView);
    }

    @Override
    public int getItemViewType(int position) {
        return CreditCardRaidersActivity.RAIDERS_MIDDLE_LABEL;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        HotTopicHolder topicHolder= (HotTopicHolder) holder;
        topicHolder.textView.setText(text);
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    private class HotTopicHolder extends RecyclerView.ViewHolder{
        private TextView textView;
        private HotTopicHolder(View itemView) {
            super(itemView);
            textView= (TextView) itemView;
        }
    }
}
